Skip to content

feat(app-shell): send the console UI language as context.uiLocale on the AI chat request - #34845

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-34639-chat-ui-locale
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-34639-chat-ui-locale

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

Fixes #34639

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:AI 对话请求的 body.context 新增 uiLocale,值为控制台当前解析出的界面语言(useObjectTranslation().language),其余字段不变。
  • 为什么改:服务端此前只看得到浏览器的 Accept-Language,中文提问 + 英文控制台时,回复让用户点「开始搭建」,而计划卡按钮显示的是 "Build it";cloud PR fix(objectql,cli): 巡检随引擎一起停 —— unreadableObjects 不再被关停污染 (#4747) #4815 的 consoleUiLocaleOf 读这个键来选按钮文案。
  • 风险与回滚:风险低,只是请求体多一个字符串键,服务端自行校验、不认识就丢弃;回滚即 revert 本 PR,服务端退回按回复语言选文案(今天的行为)。
  • 先看:ui/packages/app-shell/src/console/ai/AiChatPage.tsx(useObjectChat 的 body.context 末尾新增的 uiLocale: language 一行);ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.uiLocale-34639.test.tsx。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/app-shell/src/console/ai/__tests__/AiChatPage.uiLocale-34639.test.tsx,预期 5 个测试全部通过。
  • 需要你做的:无,席位落地。

What changes

  • ChatPane (AiChatPage.tsx) already read const { t, language } = useObjectTranslation(). The useObjectChat({ body: { context } }) call now adds uiLocale: language beside activeApp, agentName, autoPublishAiBuilds, packageId and surface. The value is sent as is; there is no client-side normalisation, because the consumer (objectstack-ai/cloud PR fix(objectql,cli): 巡检随引擎一起停 —— unreadableObjects 不再被关停污染 (#4747) #4815, consoleUiLocaleOf) validates it.
  • Console dock: read ui/packages/app-shell/src/layout/ChatDock.tsx and ChatDockConversation.tsx. The dock does not build its own chat request. It mounts the same ChatPane, so this one change covers the dock too. No dock file is edited. The only non-test useObjectChat( call sites under ui/packages are AiChatPage.tsx and the SDUI plugin-chatbot renderer, which is not the console's AI chat.
  • Changeset: .changeset/34639-ai-chat-ui-locale.md, @object-ui/app-shell patch.

Tests

New file AiChatPage.uiLocale-34639.test.tsx. It renders ChatPane with a real I18nProvider and with useObjectChat replaced by an options recorder, the same harness as AiChatPage.surfaceChipLabel-8219.test.tsx. The expected value is read from a probe under the same provider, so the pin does not depend on how the provider spells a tag. It checks:

  1. en / zh / de consoles: context.uiLocale equals the resolved UI language (non-empty string).
  2. Chinese thread under an English console versus a Chinese console: each sends its own console's language, and the two values differ.
  3. The rest of the context is unchanged: keys are exactly agentName, autoPublishAiBuilds, uiLocale for a pane with no app, package or surface.

No shared ChatPane harness file exists under console/ai/__tests__/, so the pin is its own card-named file.

Targeted run on head 82eed1d (after merging origin/main dfbc316)
pnpm --dir ui exec vitest run --maxWorkers=2 \
  packages/app-shell/src/console/ai/__tests__/AiChatPage.uiLocale-34639.test.tsx \
  packages/app-shell/src/console/ai/__tests__/AiChatPage.surfaceChipLabel-8219.test.tsx \
  packages/app-shell/src/console/ai/__tests__/AiChatPage.planCardLocale.test.tsx
 Test Files  3 passed (3)
      Tests  26 passed (26)
pnpm --filter @object-ui/app-shell run type-check   (tsc --noEmit && tsc -p tsconfig.test.json)
os-verify-lock: VERDICT command-exit 0
Ablation (fix committed first; mutation through scripts/ablation-replace.mjs)

Deleted the line uiLocale: language, (anchor 1 -> 0, blob 6e4da2c7 -> e6d51027). The test imports ../AiChatPage from source, so no build step sits between the mutation and the run.

× en console: context.uiLocale is the resolved UI language        expected undefined to be 'en'
× zh console: context.uiLocale is the resolved UI language        expected undefined to be 'zh'
× de console: context.uiLocale is the resolved UI language        expected undefined to be 'de'
× the value follows the console, not the conversation ...         expected undefined to be 'en'
× the rest of the context is unchanged beside it                  expected [ 'agentName', 'autoPublishAiBuilds' ] to deeply equal [ 'agentName', …(2) ]
 Tests  5 failed (5)
restore: blob after restore 6e4da2c7 == blob at HEAD; git diff HEAD empty

Acceptance notes

Verification

Local gate families on head 82eed1d (dispatch-gates --commands, 38 derived)
  • All 38 derived commands exited 0. Exit codes were captured before any pipe and are recorded per command. They include pnpm --dir ui exec vitest run scripts/ (Tests 5077 passed, 2 skipped), pnpm check:nul-bytes, pnpm check:cross-package-test-inputs, pnpm check:test-source-alias, pnpm check:type-check-coverage, pnpm check:type-check-debt, node scripts/check-adr-0087-registration.mjs --base origin/main, node scripts/check-empty-changeset.mjs --base origin/main and node scripts/check-sdui-manifest.mjs.
  • dispatch-gates --ran: 38 derived famil(ies) accounted for — 38 run, 0 NOT-MEASURED.
  • Extra runs: pnpm check:changeset-fixed (its roster sits under .changeset/) exit 0. pnpm check:new-line-citations (ui) gave VERDICT new-cross-file-line-citations: 0 new citation(s).
  • Full repo-wide families, the type-check lanes and test:repo belong to CI.

Generated by Claude Code

…the AI chat request

ChatPane already resolves the console's language; it now rides the chat
request body beside agentName/activeApp/packageId/surface, so the server
can name a card control the way the card renders it. The console dock
mounts the same ChatPane and is covered by the same change.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 17, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa

Red check read (area o3-H) · 2026-11-17T13:38Z

Lint UI failed on head 82eed1dc (job 134075333933). It is this PR's own: the only error in the log is in the new test file.

  • ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.uiLocale-34639.test.tsx:82:3 — react-hooks/globals: LanguageProbe assigns the module-level probedLanguage during render.

Every other hit in the job is a pre-existing warning. A fix round on this branch follows (capture the language without reassigning a module variable during render, e.g. a ref or a callback prop), then a delta L1 read.

…render-time write

The uiLocale probe assigned a module-level variable during render, which
react-hooks/globals rejects. It now reports the resolved language through a
callback prop from an effect; render() flushes effects before it returns, so
every assertion reads the same value as before.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgQsdnyS4QdR8stjDa

L1 review (L1-d) · 2026-11-17T14:42Z

L1: ACCEPT
Head-sha: 06a6d9c770f6575209bcd8ac1a1908b09ab8d301

Read at that head: the file list (3 paths), the full diff, the PR body, card #34639 with triage 6938637776, claim 6947851082, os-dev reports 6949522160 (round 1, head 82eed1d) and 6951234325 (fix round, head 06a6d9c), and the 52 check-runs. This is the first L1 read of this PR.

Checklist

  • Shape: draft, base main, Fixes #34639. The card's two Expected items are delivered:
    • body.context.uiLocale = language (a string).
    • Nothing else changes. The context keys of a pane with no app, package or surface are exactly agentName, autoPublishAiBuilds and uiLocale.
      The key spelling is the one triage asked to be named on the card. No other open card sits beside a keyword.
  • Scope vs claim: AiChatPage.tsx (one line inside the useObjectChat({ body: { context } }) call), a new card-named test under console/ai/__tests__/, and the root changeset. All inside the claim's file surface. The dock clause is resolved by reading, and the body states it: ChatDock/ChatDockConversation mount the same ChatPane and build no request of their own, so no dock file is edited. No existing test is touched.
  • Value source: language is ChatPane's own useObjectTranslation() reading (AiChatPage.tsx:1816, inside ChatPane at :1788), the same hook that renders the pane's strings. The value is sent unnormalised, as the card's consumer contract wants: the cloud route validates against PLATFORM_LOCALE_TAGS / read aliases and drops anything else.
  • Changeset: @object-ui/app-shell is private: true, and .changeset/config.json versions private packages (privatePackages.version: true). 39 changesets on main name it, so a patch entry is the house form. Sentences checked against the diff:
    • "on the AI page and in the console dock": the one ChatPane, which the dock mounts.
    • "beside the existing agentName, activeApp, packageId and surface keys": true.
    • "the console's resolved language tag, sent as is": true.
    • "Nothing else in the request changes": the key-set test pins it.
      All true.
  • Clause-② / Metadata-protocol: no / none in the claim, the body and the changeset. The chat body is an advisory context bag read by cloud. There is no open-source server reader of the chat context under packages/ that could reject an unknown key, and no exported type or schema changes. No contract face.
  • Governed: check-governed-merges.mjs --pr 34845 gives 0 of 3 paths and 164 lines, so not Tier H.
  • Tests:
    • 5 tests render the real ChatPane under a real I18nProvider (en/zh/de), with useObjectChat recording its options. The options are the request body under assertion.
    • The expected value comes from a probe under the same provider, so the pin does not hard-code a tag spelling.
    • The "follows the console, not the conversation" case (a Chinese thread under an English console) is the card's scenario.
    • The fix round moved the probe's write into an effect: this round's Lint UI red was react-hooks/globals. The CONTROL is the old file through eslint (exit 1 at 82:3), and the new file is clean.
    • Ablation at the final head (uiLocale: language, deleted): 5 of 5 red. Restore leaves the blob equal to HEAD.
  • CI at this head: Lint UI (red on 82eed1d, now success), Type Check UI, Test UI (all 16 shards), Build & E2E UI, Live E2E UI, Lint & Repo Gates, TypeScript Type Check, Check Changeset and the Governed Surface Queue Guard all success. The rest are skipped by path filter.

Must-fix

None.

Should-fix

None.

Notes

  • N1, stale readings in the body: the Verification and ablation readings were taken at round-1 head 82eed1d and are labelled with it. The final-head readings (eslint, 5/5 and 26/26 tests, type-check, the ablation) are in fix-round report 6951234325. Only the test file changed between the two heads, so the body stays true as worded. No edit is owed.
  • N2, no live reading: the consumer is cloud PR fix(objectql,cli): 巡检随引擎一起停 —— unreadableObjects 不再被关停污染 (#4747) #4815 (consoleUiLocaleOf). An open-source boot has no chat route that reads the key, so the request-body assertion is the measurable surface. cloud#4802 closes only after a pin move carries this.

Landing: not governed, all checks green. Area o3-H lands it. A later push owes a delta read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa

Landing (area o3-H) · 2026-11-17T14:43Z

Reading Value
L1 ACCEPT (L1-d, comment 6951310101) on head 06a6d9c770f6575209bcd8ac1a1908b09ab8d301, no must-fix, no should-fix, notes only
CI on that head 39 success, 13 skipped (path filter), 0 failed or pending (Lint UI red on 82eed1d fixed by the fix round); mergeable_state: clean
check-governed-merges.mjs --pr 34845 NOT governed; 164 changed lines ≤ 3000
K (7752cac7..origin/main, first-parent) 1 (< 15)

State change: ready + auto-merge enabled; Fixes #34639 closes the card on merge. Cloud consumer: objectstack-ai/cloud PR #4815; cloud#4802 closes after a pin move carries this.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 14:44
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit b3c3acd Nov 17, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34639-chat-ui-locale branch November 17, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI chat: send the console's resolved UI language (context.uiLocale) on the chat request, so a reply names the plan card's button as the card renders it

2 participants